import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

const bootstrap = async () => {
  const app = await NestFactory.create(AppModule);

  // 定义全局前缀
  app.setGlobalPrefix('/v1/api');

  // 增加swagger
  const options = new DocumentBuilder()
    .addBearerAuth()
    .setTitle('接口文档')
    .setDescription('后端提供的接口文档')
    .setVersion('1.0')
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('/api-doc', app, document);

  await app.listen(3000);
  console.log('接口文档地址是：http://localhost:3000/api-doc');
};
bootstrap();
